/////////////////////////
// 	DDList.h	:	v0010
//	Written by 	:	Li	Haijun
//	Compiler	:	Microsoft Visual C++ 4.0
//	v0010		:	Dec.2.1996
/////////////////////////

/////////////////////////////////////////////////////////////////////////////
// CDButton class
#ifndef __CBLIST_H__
#define __CBLIST_H__

#include	"stdafx.h"

#include	"ddapi.h"

#include	"Marco.h"
#include	"puthz.h"

/////////////////////////////////////////
// to test whether a List is clicked
/////////////////////////////////////////
BOOL	LeftButtonDownOnList(int xPos, int yPos);
// to test whether cursor is moved on a List
BOOL	MouseMoveOnList(int xPos, int yPos);
/////////////////////////////////////////
//	to release all bitmap of list when you exit this game
void	FACE_DeleteAllList() ;
////////////////////////////////////////
// to blit all bitmap of list . This function is just for class CDDMenu
void	FACE_BlitAllList() ;
///////////////////////////////////////////////////////////////////////
// class declear
class CDDList
{
	//member
public:
// the surface that this button is load on
	CDDSurface	m_BitmapSurface;
// Attributes
public:

	int		m_nFileNameId;	// name of this DIB file name
	SIZE	m_szOneBitmap;	// the size of one state of a bitmap button
	RECT	m_rTotal;		// there is four state of a bitmap button in a DIB file	
	RECT	m_rCurrent;		// the rectangle of current state bitmap button
	int		m_dwX, m_dwY;		// the position of a bitmap button on the surface

	int  m_nID;		// button id
	int  m_nState;	// button state,0-up,1-down,2-disable,3-focus
	int	 m_nPreviousState;	// to store the previous button state
	int  m_nPart;	// how many part should the dib image file be devided
					// that means,how many state image in one dib file

	BOOL	m_bSerFlag ;	// to flag whether there is a serial number on this list
	char	m_ShowSer[10]; // the string that show in this list
	class	CDDText m_Serial;		// the string attribute of this list
	int		m_dSerialX, m_dSerialY;		// to store the offset that the letters should be placed relative to the top-left point of this list

	char	m_ShowString[1024]; // the string that show in this list
	class	CDDText m_String;		// the string attribute of this list
	int		m_dTextX, m_dTextY;		// to store the offset that the letters should be placed relative to the top-left point of this list

	BOOL m_bEnableSound;	// true for enable sound effects
public:
	CDDList();		//constructor
	~CDDList();		//destructor

// Initialize the data member
public:
// Operations
public:	
	// initializes
	BOOL PreLoad(int FilenameId, int x, int y, int OneBitmapWidth=0, int OneBitmapHeight=0); //, int part);	// always used in the contructor of its parent
	void Release(void);
	void LoadSound(LPCTSTR lpszDown, LPCTSTR lpszUp, LPCTSTR lpszDisable);	// for playing sound

	// attributes
	// set the state of this list
	void SetID(int ID);	//to set this list's ID
	// set the state of this list
	void SetState(int state);	// let list up or down or ...
	// to get the state of this list's state
	int	 GetState(){return m_nState;}	// get list state
	// to get the size of this list
	SIZE GetSize(void){return m_szOneBitmap;}
	/////////////////////////////////////////
	// to set all List's state when change the command state
	void SetAllListState(int state);
	// to set the string position
	void SetStringPos(int x, int y){ m_dTextX=x; m_dTextY=y; }
	// to set the serial namber of this list if it have
	void SetSerial( LPCTSTR serial ) ;

	// operations
	//to test if the given point on this button
	BOOL OnList( int x, int y);
	//blit the current part of image to the direct surface and show it
	void Show(void);													      
	// to blit the current part of image to the back buffer
	void Blit(void);
	////////////////////////////////////////////
	//	to show the string of this list
	void BlitString();
	// to update the area of current part of image from back buffer to front buffer
	void Update(void);
};
///////////////////////////////////////////////////////////////////////
// class declear
class CDDListUnit
{
	// Data member
	public:
		CDDList *	m_pList[MAX_LISTINUNIT];
		int			m_nSerialNum;	//to record the serial number of the list 
								// (in this list-unit) that been clicked 
	public:
		// constuctor
		CDDListUnit();
		~CDDListUnit();
		// to set state of each LIST that in this list-unit
		void	SetMemberState( int state );
		// to show all list in this list-unit
		void	Show( );
		// to blit all list in this list-unit
		void	Blit( );
		// to update all list in this list-unit
		void	Update( );
		// to release all list in this list-unit
		void	Release();
};


/////////////////////////////////////////////////////////////////////////////
#endif

